package com.tencent.mapper;

import com.tencent.entity.Order;
import com.tencent.entity.SetMeal;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

public interface ShowOrderMapper {
    
    List<Order> findByName(String queryString);

//    select t_order.id,member_id memberId,orderDate,orderType,orderStatus,setmeal_id
//    setMealId,fileNumber,name,phoneNumber
//    from t_order JOIN t_member
//    on t_order.member_id=t_member.id
//            <where>
//            <if test="queryString != null and queryString != ''">
//    and name = #{queryString} or idCard=#{queryString} or phonenumber=#{queryString}
//            </if>
//        </where>
    //测试
    @Select("    select t_order.id,member_id memberId,orderDate,orderType,orderStatus,setmeal_id" +
            "    setMealId,fileNumber,name,phoneNumber" +
            "    from t_order JOIN t_member" +
            "    on t_order.member_id=t_member.id")
   List<Order> findByName2(String queryString);

    @Delete("delete from t_order where id=#{id}")
    int deleteByIdInfo(int id);

    @Update("update t_order set orderStatus ='已就诊' where id=#{id} ")
    int updateByIdInfo(int id);

    @Insert("insert into t_order(member_id,orderDate,orderType,orderStatus) values (#{memberId},#{orderDate},'微信预约','未就诊')")
    int addInfo1(Order order);

    @Insert("insert into t_member(name,fileNumber,phoneNumber) values (#{name},#{fileNumber},#{phoneNumber})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    int addInfo2(Order order);

    @Select("select * from t_setmeal ")
    List<SetMeal> findAll();

    @Select("select count(*) from t_ordersetting where orderdate = #{date}")
    int selectSetByDate(Date date);

    @Select("select *from t_order where id=#{id}")
    Order selectById(int id);
}
